#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using i128 = __int128;
const int N = 1e6 + 5;

stack<string> a, b, c;
int n, len, strl;

// 打印当前三个栈里面的铁盘“***”的状态
void print() {
    stack<string> ta = a, tb = b, tc = c;
    for (int i = 1; i <= len; i++) cout << ".";  // 第一排的‘·’
    cout << endl;
    int mid = (strl - 1) / 2;
    // 第二排的柱子头
    cout << '.' << string(mid, '.') << '|' << string(mid, '.') << '.'
         << string(mid, '.') << '|' << string(mid, '.') << '.'
         << string(mid, '.') << '|' << string(mid, '.') << '.' << endl;
    // 盘子行
    for (int i = n; i >= 1; i--) {
        string line = ".";
        // A柱
        if (ta.size() == i) {
            string disk = ta.top();
            int pad = (strl - disk.size()) / 2;
            line +=
                string(pad, '.') + disk + string(strl - disk.size() - pad, '.');
            ta.pop();
        } else {
            line += string(mid, '.') + '|' + string(mid, '.');
        }
        line += '.';
        // B柱
        if (tb.size() == i) {
            string disk = tb.top();
            int pad = (strl - disk.size()) / 2;
            line +=
                string(pad, '.') + disk + string(strl - disk.size() - pad, '.');
            tb.pop();
        } else {
            line += string(mid, '.') + '|' + string(mid, '.');
        }
        line += '.';
        // C柱
        if (tc.size() == i) {
            string disk = tc.top();
            int pad = (strl - disk.size()) / 2;
            line +=
                string(pad, '.') + disk + string(strl - disk.size() - pad, '.');
            tc.pop();
        } else {
            line += string(mid, '.') + '|' + string(mid, '.');
        }
        line += '.';

        cout << line << endl;
    }
}

// 处理铁盘在三个柱子之间移动
void midprint(char p, char q) {
    string temp;
    if (p == 'a') {
        temp = a.top();
        a.pop();
    } else if (p == 'b') {
        temp = b.top();
        b.pop();
    } else {
        temp = c.top();
        c.pop();
    }
    if (q == 'a') {
        a.push(temp);
    } else if (q == 'b') {
        b.push(temp);
    } else {
        c.push(temp);
    }
    for (int i = 0; i < len; i++) {
        cout << "-";
    }
    cout << endl;

    print();
}

// 处理汉洛塔问题
void hlt(int n, char a, char c, char b) {  // 顺序为 源柱 目标柱 辅助柱
    if (n == 1)
        midprint(a, c);
    else {
        hlt(n - 1, a, b, c);
        midprint(a, c);
        hlt(n - 1, b, c, a);
    }
    return;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cin >> n;
    len = 3 * (2 * n + 1) + 4;  // 一排共有多少字符
    strl = 2 * n + 1;           // 最大铁盘的宽度即使柱子的宽度
    stack<string> ori;          // 用于构造初始铁盘的位置，中间存储
    int sum = 0;
    for (int i = n; i >= 1; i--) {
        a.push(string(2 * i + 1, '*'));
    }
    print();
    if (n % 2 == 0) {
        hlt(n, 'a', 'c', 'b');
    } else {
        hlt(n, 'a', 'b', 'c');
    }

    return 0;
}